Skip to content

[CodeStyle][py2] remove the next method for python2 compatibility (PEP 3114) #47728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

SigureMo
Copy link
Member

@SigureMo SigureMo commented Nov 7, 2022

PR types

Others

PR changes

Others

Describe

Python2 里迭代器里要求包含 next 方法,而在 Python3 中则使用了 __next__ 方法取代了 next 方法1,目前为了兼容 Python2,一些代码添加了 next 方法,但只是调用了了一下 __next__,现在这个 next 方法是没有必要的了

Related links

Footnotes

  1. PEP 3114 – Renaming iterator.next() to iterator.__next__()

@paddle-bot
Copy link

paddle-bot bot commented Nov 7, 2022

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added contributor External developers status: proposed labels Nov 7, 2022
@SigureMo SigureMo changed the title [CodeStyle][py2] remove the next method for python2 compatibility (PEP 3114) [WIP][CodeStyle][py2] remove the next method for python2 compatibility (PEP 3114) Nov 7, 2022
implementing iterator protocol of Python 2.x inside
PaddlePaddle framework.
'''
return self.__next__()
Copy link
Member Author

@SigureMo SigureMo Nov 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

This method should not be called by users directly.

这并不是一个供用户调用的 API,因此这里删除它应该没有问题

@SigureMo SigureMo changed the title [WIP][CodeStyle][py2] remove the next method for python2 compatibility (PEP 3114) [CodeStyle][py2] remove the next method for python2 compatibility (PEP 3114) Nov 7, 2022
@luotao1 luotao1 self-assigned this Nov 8, 2022
@luotao1 luotao1 requested a review from zoooo0820 November 8, 2022 06:24
Copy link
Contributor

@zoooo0820 zoooo0820 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@jeff41404 jeff41404 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@Ligoml Ligoml left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@luotao1 luotao1 merged commit 4061b1b into PaddlePaddle:develop Nov 8, 2022
@SigureMo SigureMo deleted the py2/fix/pep-3114-next-to-__next__ branch November 8, 2022 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants